package com.aaa.controller;

import com.aaa.pojo.Student;
import com.aaa.service.StudentService;
import com.aaa.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class StudentController {
    //    @PutMapping  查询 get提交  删除 delete  修改 PUT提交  添加 post提交
   @Autowired
  private StudentService studentService;
    //查
    @GetMapping("/findById/{sid}")
    public Result findById(@PathVariable  Integer sid){
        Result byId = studentService.findById(sid);
        return byId;
    }
    @GetMapping("/findAll")
    public Result findAll(){
        Result all = studentService.findAll();
        return all;

    }
    //增
    @PostMapping("insert")
    public  Result insert(@RequestBody Student student){
        Result insert = studentService.insert(student);
        return insert;
    }
    //改
@PutMapping("/update")
    public  Result result(@RequestBody Student student){
    Result update = studentService.update(student);
    return update;
}
@DeleteMapping("delete/{sid}")
    public Result delete(@PathVariable Integer sid){
    Result delete = studentService.delete(sid);
    return delete;
}
}
